﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using NTwitter;
using TwitterClient2.Controller;

namespace TwitterClient2.Components
{
    class PanelTweet : Panel
    {
        public Label labelDate;
        public Label labelText;
        public LinkLabel labelName;
        public byte location;
        public TwitterClientController controller = TwitterClientController.getInstance();

        public PanelTweet(byte location)
        {
            this.location = location;
            InitializeComponent();

        }
        private void InitializeComponent()
        {
            this.labelDate = new System.Windows.Forms.Label();
            this.labelText = new System.Windows.Forms.Label();
            this.labelName = new System.Windows.Forms.LinkLabel();
            this.SuspendLayout();
            // 
            // labelDate
            // 
            this.labelDate.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Italic);
            this.labelDate.ForeColor = System.Drawing.SystemColors.GrayText;
            this.labelDate.Location = new System.Drawing.Point(100, 2);
            this.labelDate.Name = "labelDate";
            this.labelDate.Size = new System.Drawing.Size(100, 20);
            this.labelDate.Text = "label2";
            // 
            // labelText
            // 
            this.labelText.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular);
            this.labelText.Location = new System.Drawing.Point(2, 22);
            this.labelText.Name = "labelText";
            this.labelText.Size = new System.Drawing.Size(196, 80);
            // 
            // labelName
            // 
            this.labelName.Location = new System.Drawing.Point(2, 2);
            this.labelName.Name = "labelName";
            this.labelName.Size = new System.Drawing.Size(100, 20);
            this.labelName.TabIndex = 0;
            this.labelName.Text = "linkLabel1";
            this.labelName.Click += new System.EventHandler(this.labelNameClick);
            // 
            // PanelTweet
            // 
            this.BackColor = System.Drawing.Color.WhiteSmoke;
            this.Controls.Add(this.labelDate);
            this.Controls.Add(this.labelName);
            this.Controls.Add(this.labelText);
            this.Size = new System.Drawing.Size(200, 100);
            this.ResumeLayout(false);

        }

        private void labelNameClick(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            this.Parent.Enabled = false;
            LinkLabel linkLabel = (LinkLabel)sender;
            String user = linkLabel.Text;
            TwitterClientEvent tEvent = new TwitterClientEvent();
            tEvent.paramList.Add(user);
            tEvent.paramList.Add(location);
            this.controller.performUserInput(TwitterClientController.USER_CLICK_HOME_OR_SEARCH, tEvent);
            this.Parent.Enabled = true;
            Cursor.Current = Cursors.Default;
        }

    }
}
